import React  from "react";
export default function Name(WrappedComponent) {
  return class withComponent extends React.Component {
    // 修改调试工具显示的类名为"with" + WrappedComponent.name
    // react调用工具,会优先显示组件的displayName静态属性,
    // 如果没有则显示name静态属性.name属性只能获取不能赋值
    static displayName = "with" + WrappedComponent.name;
    state = {
      username: "",
      password: "",
      repassword: "",
    };

    handleChange = (name) => {
      return (e) => {
        this.setState({
          [name]: e.target.value,
        });
      };
    };

    render() {
      return (
        <WrappedComponent
          state={this.state}
        // 展开传输过来的数据，就不用一一列出
          {...this.props}
          handleChange={this.handleChange}
        ></WrappedComponent>
      );
    }
  };
  
}